<template>
	<view>
		<view class="cu-custom-content" :class="contentClass" :style="topStyle" @tap="topClick()">
			
			<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
				<view class="cu-bar fixed" :style="style" >
					<view class="action">
						<text class="cuIcon-back" v-if="backIcon"></text>
						<slot name="backText"></slot>
					</view>
					<view class="content" :style="[{top:StatusBar + 'px'}]">
						<slot name="content"></slot>
					</view>
					<slot name="right"></slot>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				scrollTop: 0,
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar= this.StatusBar;
				var CustomBar= this.CustomBar;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				
				if(this.scrollTop > 0){
					let bgOpColor = this.scrollTop / this.cuCustomTop;
					
					style += `background-color:rgba(255,255,255,${bgOpColor});color:${this.themeColor}`;
				}else{
					style += `color:#fff`;
				}
				return style
			},
			topStyle(){
				if(this.bgImage.length>0){
					return `background:url(${this.bgImage}) no-repeat center center / cover`;
				}
				return '';
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			backIcon:{
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			contentClass:{
				type: String,
				default: ''
			},
			cuCustomTop:{
				type: Number,
				default: 0
			},
			// cpsList:{
			// 	type: Object,
			// 	default: []
			// },
			goVideo:{
				type: Boolean,
				default: true
			},
		},
		methods: {
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
				
				return false;
				
			},
			pageScroll(e){
				if(this.cuCustomTop <= 0) return;
				
				this.scrollTop = e.scrollTop;
			},
			topClick(){
				if(!this.goVideo) return;
				
				this.bannerClick(0);
			}
		}
	}
</script>

<style lang="scss">
	.top-share{
		padding: 3px 10px;
		border-radius: 15px;
	}
	.cu-custom-content{
		height: 12rem;
	}
	.cu-avatar.lg {
		height: 130rpx;
		width: 130rpx;
	}
</style>
